﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<object id="ActiveX996" classid="clsid:F48D2AD3-23FF-4882-8A9A-FB540AA718F5"  codebase="CISActiveX.cab" style="display: none;"></object>
<form id="form1">
    <table class="form">
        <tr>
            <td class="formTitle">卡号：</td>
            <td class="formValue">
                <input id="kh" class="form-control" placeholder="请输入卡号" value="c0004876" />
            </td>
            <td>
                <input type="button" class="btn btn-primary btn-md" id="btn_1" value="院内心电报告调阅" />
            </td>
        </tr>
        <tr>
            <td class="formTitle">挂号ID：</td>
            <td class="formValue">
                <input id="ghid" class="form-control" placeholder="请输入挂号ID" />
            </td>
            <td class="formTitle">姓名：</td>
            <td class="formValue">
                <input id="ghname" class="form-control" placeholder="请输入姓名" />
            </td>
            <td class="formTitle">开始时间：</td>
            <td class="formValue">
                <input id="startdate" type="text" class="form-control input-wdatepicker form-an" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" value="@DateTime.Now.ToString("yyyy-MM-dd 00:00:00")" />
            </td>
        </tr>
        <tr>
            <td class="formTitle">结束时间：</td>
            <td class="formValue">
                <input id="enddate" type="text" class="form-control input-wdatepicker form-an" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" value="@DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")" />
            </td>
            <td>
                <input type="button" class="btn btn-primary btn-md" id="btn_7" value="院内影像B超报告调阅" />
            </td>
            <td>
                <input type="button" class="btn btn-primary btn-md" id="btn_8" value="检验院内报告调阅" />
            </td>
        </tr>
        <tr>
            <td class="formTitle">患者编号：</td>
            <td class="formValue">
                <input id="patid" class="form-control" placeholder="请输入患者唯一编号" />
            </td>
            <td class="formTitle">申请单号：</td>
            <td class="formValue">
                <input id="orderno" class="form-control" placeholder="请输入申请单号" />
            </td>
            <td>
                <input type="button" class="btn btn-primary btn-md" id="btn_3" value="远程医疗心电申请" />
            </td>
        </tr>
        <tr>
            <td class="formTitle">病人唯一编码：</td>
            <td class="formValue">
                <input id="jypatid" class="form-control" placeholder="请输入病人唯一编码" />
            </td>
            <td class="formTitle">就诊流水号：</td>
            <td class="formValue">
                <input id="jzlsh" class="form-control" placeholder="请输入就诊流水号" />
            </td>
            <td>
                <input type="button" class="btn btn-primary btn-md" id="btn_5" value="检验申请" />
            </td>
        </tr>
        <tr>
            <td class="formTitle">卡号：</td>
            <td class="formValue">
                <input id="yxkh" class="form-control" placeholder="请输入卡号" />
            </td>
            <td class="formTitle">申请单号：</td>
            <td class="formValue">
                <input id="yxnum" class="form-control" placeholder="请输入申请单号" />
            </td>
            <td>
                <input type="button" class="btn btn-primary btn-md" id="btn_6" value="远程医疗影像申请" />
            </td>
        </tr>
        <tr>
            <td class="formTitle">卡号：</td>
            <td class="formValue">
                <input id="xdkh" class="form-control" placeholder="请输入卡号" />
            </td>
            <td class="formTitle">申请单号：</td>
            <td class="formValue">
                <input id="xdnum" class="form-control" placeholder="请输入申请单号" />
            </td>
            <td>
                <input type="button" class="btn btn-primary btn-md" id="btn_9" value="远程医疗心电调阅" />
            </td>
        </tr>
    </table>
</form>


<script>
    $(function () {
        $('#btn_1').click(function () {
             $.ajax({
                type: "POST",
                 url: "@Url.Action("chakanmingxidiaoyong")",
                 data: { kh: $('#kh').val() },
                dataType: "xml",  //参数类型为xml
                contentType: "application/x-www-form-urlencoded",//使用的xml格式的
                 error: function (error) {
                     var resp = JSON.parse(JSON.parse(error.responseText).data);
                     if (resp !== undefined && resp.length > 0) {
                         sessionStorage.setItem('XindianList', JSON.stringify(resp));
                         $.modalOpen({
                             id: "Form",
                             title: "心电详情",
                             url: "@Url.Action("ViewXindianList")",
                             width: "700px",
                             height: "530px",
                             btn:null
                         });
                    }
                }
            })
        });
        $('#btn_2').on("click", function () {
            window.open($('#imgsrc').val());
        });

        $('#btn_3').click(function () {
             $.ajax({
                type: "POST",
                 url: "@Url.Action("xindianshenqing")",
                 data: { patid: $('#patid').val(), orderno: $('#orderno').val()},
                dataType: "xml",  //参数类型为xml
                contentType: "application/x-www-form-urlencoded",//使用的xml格式的
                error: function (error) {
                    if (JSON.parse(JSON.parse(error.responseText).data)[0].Return === "1") {
                        window.open("http://www.baidu.com/", "_blank");
                    }
                }
            })
        });

        $('#btn_4').click(function () {
            if (!$('#form1').formValid()) {
                return false;
            }
             $.ajax({
                type: "POST",
                 url: "@Url.Action("xindianshenqing")",
                 data: getxindianshenqingPostdata(),
                dataType: "xml",  //参数类型为xml
                contentType: "application/x-www-form-urlencoded",//使用的xml格式的
                error: function (error) {
                    if (JSON.parse(JSON.parse(error.responseText).data)[0].Return === "1") {
                        window.open("http://www.baidu.com/", "_blank");
                    }
                }
            })
        });

          $('#btn_5').click(function () {
             $.ajax({
                type: "POST",
                 url: "@Url.Action("jianyanshenqing")",
                 data: {patid: $('#jypatid').val(), jzlsh: $('#jzlsh').val() },
                dataType: "xml",  //参数类型为xml
                contentType: "application/x-www-form-urlencoded",//使用的xml格式的
                error: function (error) {
                    if (JSON.parse(JSON.parse(error.responseText).data)[0].return === "1") {
                        window.open("http://www.baidu.com/", "_blank");
                    }
                }
            })
        });

             $('#btn_6').click(function () {
             $.ajax({
                type: "POST",
                 url: "@Url.Action("yingxiangshenqing")",
                 data: { patid: $('#yxkh').val(), num: $('#yxnum').val() },
                dataType: "xml",  //参数类型为xml
                contentType: "application/x-www-form-urlencoded",//使用的xml格式的
                error: function (error) {
                    if (JSON.parse(JSON.parse(error.responseText).data)[0].return === "1") {
                        window.open("http://www.baidu.com/", "_blank");
                    }
                }
            })
        });

         $('#btn_9').click(function () {
             $.ajax({
                type: "POST",
                 url: "@Url.Action("xindiandiaoyue")",
                 data: { kh: $('#xdkh').val(), orderno: $('#xdnum').val() },
                dataType: "xml",  //参数类型为xml
                contentType: "application/x-www-form-urlencoded",//使用的xml格式的
                error: function (error) {
                    if (JSON.parse(JSON.parse(error.responseText).data)[0].return === "1") {
                        window.open("http://www.baidu.com/", "_blank");
                    }
                }
            })
        });

        $('#btn_7').click(function () {
            var str = "http://40.21.114.251:8888/ReportList.aspx?hoscode=&patientid=&hispatientid=" + $('#ghid').val() + "&hissheetid=&name=" + $('#ghname').val() + "&startdate=" + $('#startdate').val() + "&enddate=" + $('#enddate').val()+"&sex=";
            window.open(str, "_blank");
        });

             $('#btn_8').click(function () {
	             var activeX = document.getElementById("ActiveX996");
	            activeX.jianyandiaoyue();
        });
        });

    function getxindianshenqingPostdata() {
        var data = $("#form1").formSerialize();
        return data;
    }

    function browserIsIe() {
        if (!!window.ActiveXObject || "ActiveXObject" in window) {
            return true;
        }
        else {
            return false;
        }
    }

    function createIframe(imgSrc) {
        //如果隐藏的iframe不存在则创建
        if ($("#IframeReportImg").length === 0) {
            $('<iframe style="display:none;" id="IframeReportImg" name="IframeReportImg" onload="downloadImg();" width="0" height="0" src="about:blank"></iframe>').appendTo("body");
        }
        //iframe的src属性如不指向图片地址,则手动修改,加载图片
        if ($('#IframeReportImg').attr("src") != imgSrc) {
            $('#IframeReportImg').attr("src", imgSrc);
        } else {
            //如指向图片地址,直接调用下载方法
            downloadImg();
        }
    }
    //下载图片的函数
    function downloadImg() {
        //iframe的src属性不为空,调用execCommand(),保存图片
        if ($('#IframeReportImg').src != "about:blank") {
            window.frames["IframeReportImg"].document.execCommand("SaveAs");
        }
    }
</script>

